var core = require('../third/qrcode/src')

var qrCode = {
    getQRCodeImg: function (text) {
        return core.createQrCodeImg(
            text,
            {
                size: parseInt(this.getQRCodeSize())
            }
        )
    },
    getQRCodeSize: function(){
        var size = 0;
        try {
            var res = wx.getSystemInfoSync();
            var scale = 750/278; //不同屏幕下QRcode的适配比例；设计稿是750宽
            var width = res.windowWidth/scale;        
            size = width;
        } catch (e) {
            // Do something when catch error
            // console.log("获取设备信息失败"+e);
        } 
        return size;
    },
}

module.exports = qrCode